#include <cstdio>
#include <set>
#include <tuple>
#include <vector>
int n;
std::vector<std::tuple<int, int>> v;
std::multiset<int> answer;
std::multiset<std::tuple<int, int>> set;
int main()
{
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);
    scanf("%d", &n);
    if (n <= 500)
    {
        for (int i = 1; i <= n; i++)
        {
            char op;
            scanf(" %c", &op);
            int l, r;
            scanf("%d%d", &l, &r);
            r--;
            if (op == 'A')
            {
                v.push_back({l, r});
            }
            else if (op == 'R')
            {
                auto it = v.begin();
                for (;;)
                {
                    if (*it == std::tuple<int, int>{l, r})
                    {
                        v.erase(it);
                        break;
                    }
                    it++;
                }
            }
            int with = 0x3f3f3f3f;
            int answer = std::get<1>(v[0]) - std::get<0>(v[0]) + 1;
            for (int i = 0; i < int(v.size()); i++)
            {
                for (int j = i + 1; j < int(v.size()); j++)
                {
                    const auto &[l, r] = v[i];
                    const auto &[x, y] = v[j];
                    int nWith, nAnswer;
                    nWith = nAnswer = 0;
                    if (l <= x && y <= r)
                    {
                        nWith = y - x + 1;
                        nAnswer = y - x + 1;
                    }
                    if (x <= l && r <= y)
                    {
                        nWith = r - l + 1;
                        nAnswer = r - l + 1;
                    }
                    if (l <= x && x <= r && r <= y)
                    {
                        nWith = r - x + 1;
                        nAnswer = y - l + 1;
                    }
                    if (x <= l && l <= y && y <= r)
                    {
                        nWith = y - l + 1;
                        nAnswer = r - x + 1;
                    }
                    if (r < x)
                    {
                        nWith = 0;
                        nAnswer = y - l + 1;
                    }
                    if (y < l)
                    {
                        nWith = 0;
                        nAnswer = r - x + 1;
                    }
                    if (nWith < with || (nWith == with && nAnswer < answer))
                    {
                        with = nWith;
                        answer = nAnswer;
                    }
                }
            }
            printf("%d\n", answer);
        }
    }
    else
    {
        set.insert({0x3f3f3f3f, 0x3f3f3f3f});
        set.insert({-0x3f3f3f3f, -0x3f3f3f3f});
        for (int i = 1; i <= n; i++)
        {
            char op;
            scanf(" %c", &op);
            int l, r;
            scanf("%d%d", &l, &r);
            r--;
            if (op == 'A')
            {
                set.insert({l, r});
                auto it = set.lower_bound({l, r});
                auto x = it;
                x--;
                auto y = it;
                y++;
                answer.insert(std::get<1>(*it) - std::get<0>(*x) + 1);
                answer.insert(std::get<1>(*y) - std::get<0>(*it) + 1);
            }
            else if (op == 'R')
            {
                auto it = set.lower_bound({l, r});
                auto x = it;
                x--;
                auto y = it;
                y++;
                answer.erase(answer.find(std::get<1>(*it) - std::get<0>(*x) + 1));
                answer.erase(answer.find(std::get<1>(*y) - std::get<0>(*it) + 1));
                set.erase(set.find({l, r}));
            }
            if (set.size() == 3)
            {
                auto it = set.begin();
                it++;
                printf("%d\n", std::get<1>(*it) - std::get<0>(*it) + 1);
            }
            else
            {
                printf("%d\n", *answer.begin());
            }
        }
    }
    return 0;
}
